home *** CD-ROM | disk | FTP | other *** search
/ SPACE 2 / SPACE - Library 2 - Volume 1.iso / telecom / 96 / c / menu.asm < prev    next >
Encoding:
Assembly Source File  |  1987-01-15  |  8.0 KB  |  253 lines

  1. ***************************************************
  2. *                    GEM menu demo                *
  3. *                                                 *
  4. *  Written by Devin Smith               11/15/86  *
  5. ***************************************************
  6.  
  7. * GST assembler
  8.  
  9.         opt     abs
  10.         section one
  11.  
  12. *-------------------------------------------------------------------------
  13. * program start - here we free up memory not used by the program
  14. *-------------------------------------------------------------------------
  15.  
  16. freemem
  17.         move.l  4(sp),A5        ;A5 now points to base page start, $100
  18.                                 ;bytes below program start
  19.         lea.l   stack,A7        ;setup new stack
  20.         move.l  $C(A5),D0       ;put length of program area in D0
  21.         add.l   $14(A5),D0      ;add length of initialized data area
  22.         add.l   #ebss-sbss,D0   ;length of uninitialized data area; this
  23.                                 ;is the bss section--it must be done this
  24.                                 ;way 'cause of the lame GST assembler
  25.         add.l   #$100,D0        ;add $100 bytes for the base page
  26.                                 ;D0 now contains all of the space this
  27.                                 ;program uses or will uses plus $100 
  28.                                 ;bytes for the base page
  29.  
  30.         move.l  D0,-(sp)        ;push amount of space to be reserved
  31.         move.l  A5,-(sp)        ;push start address of space
  32.         clr.w   -(sp)           ;meaningless, but quite necessary word
  33.         move.w  #$4A,-(sp)      ;code = SETBLOCK
  34.         trap    #1              ;GEMDOS
  35.         lea.l   12(sp),sp       ;fix sp
  36.         tst.w   D0              ;error?
  37.         bne.s   done            ;yes = terminate program
  38.  
  39. *-------------------------------------------------------------------------
  40. *  here we execute the main program and set up routines that are used to
  41. *  call AES and VDI funtions
  42. *-------------------------------------------------------------------------
  43.  
  44. start
  45.         bsr.s   main
  46. done
  47.         clr.w   -(sp)
  48.         trap    #1              ;exit to OS
  49.  
  50. aes
  51.         move.l  #aespb,D1       ;address of parameter block
  52.         move.w  #$C8,D0         ;opcode for AES
  53.         trap    #2
  54.         rts
  55.  
  56. vdi
  57.         move.l  #vdipb,D1       ;address of parameter block
  58.         moveq.l #$73,D0         ;opcode for VDI
  59.         trap    #2
  60.         rts
  61.  
  62. *-------------------------------------------------------------------------
  63. * main program starts here
  64. *-------------------------------------------------------------------------
  65.  
  66. main
  67.         clr.l   ap1resv
  68.         clr.l   ap2resv
  69.         clr.l   ap3resv
  70.         clr.l   ap4resv
  71.         move.w  #10,opcode
  72.         clr.w   sintin
  73.         move.w  #1,sintout
  74.         clr.w   saddrin
  75.         clr.w   sadrout
  76.         bsr.l   aes             ;appl_init
  77.  
  78.         move.w  #77,opcode
  79.         clr.w   sintin
  80.         move.w  #5,sintout
  81.         clr.w   saddrin
  82.         clr.w   sadrout
  83.         bsr.l   aes             ;graf_handle
  84.         move.w  intout,grhand   ;save the graphics handle
  85.  
  86.         move.w  #100,opcode
  87.         clr.w   contrl+2
  88.         move.w  #11,contrl+6
  89.         move.w  grhand,contrl+12
  90.         move.w  #1,D0
  91.         move.w  D0,intin
  92.         move.w  D0,intin+2
  93.         move.w  D0,intin+4
  94.         move.w  D0,intin+6
  95.         move.w  D0,intin+8
  96.         move.w  D0,intin+10
  97.         move.w  D0,intin+12
  98.         move.w  D0,intin+14
  99.         move.w  D0,intin+16
  100.         move.w  D0,intin+18     ;faster to use D0 than #1
  101.         move.w  #2,intin+20
  102.         bsr.l   vdi             ;open_vwork
  103.  
  104. rscload
  105.         move.w  #110,contrl
  106.         clr.w   contrl+2
  107.         move.w  #1,contrl+4
  108.         move.w  #1,contrl+6
  109.         clr.w   contrl+8
  110.         move.l  #resrce,addrin  ;address of resource filename
  111.         bsr.l   aes             ;rsrc_load
  112.         tst.w   intout          ;error?
  113.         bne.s   rscget          ;no = get address of resource data
  114.         rts                     ;yes = exit
  115.  
  116. rscget
  117.         move.w  #112,contrl
  118.         move.w  #2,contrl+2
  119.         move.w  #1,contrl+4
  120.         clr.w   contrl+6
  121.         move.w  #1,contrl+8
  122.         clr.w   intin
  123.         clr.w   intin+2
  124.         bsr.l   aes             ;rsrc_gaddr
  125.  
  126. shocurs
  127.         dc.w    $A000           ;line_a init
  128.         move.l  8(A0),A0        ;address of INTIN arrays
  129.  
  130.         clr.w   6(A0)           ;INTIN(3) = mask color index
  131.         move.w  #1,8(A0)        ;INTIN(4) = data color index
  132.  
  133.         add.l   #10,A0          ;set INTIN pointer to INTIN(5)
  134.         lea.l   mouse,A1        ;data for new cursor  mask + data
  135.         move.w  #16,D0          ;loop counter, 16 longs = 32 words
  136. show1
  137.         move.l  (A1)+,(A0)+     ;transfer bit maps to INTIN array
  138.         dbra    D0,show1
  139.  
  140.         dc.w    $A00B           ;line_a transform mouse
  141.  
  142.         dc.w    $A000           ;line_a init
  143.         move.l  8(A0),A1        ;get address of INTIN arrays again
  144.         
  145.         clr.w   (A1)
  146.         dc.w    $A009           ;line_a show mouse
  147.  
  148. menu
  149.         move.w  #30,contrl
  150.         move.w  #1,D0           ;faster to use D0 than #1
  151.         move.w  D0,contrl+2
  152.         move.w  D0,contrl+4
  153.         move.w  D0,contrl+6
  154.         clr.w   contrl+8
  155.         move.w  D0,intin        ;me_bshow = draw the menu bar
  156.         move.l  addrout,addrin  ;me_btree = address returned from rsrc_gaddr
  157.         bsr.l   aes             ;menu_bar
  158.  
  159. wait
  160.         move.w  #23,contrl
  161.         clr.w   contrl+2
  162.         move.w  #1,contrl+4
  163.         move.w  #1,contrl+6
  164.         clr.w   contrl+8
  165.         move.l  #buffer,addrin
  166.         bsr.l   aes             ;evnt_mesag
  167.  
  168.         rts
  169.  
  170. *-------------------------------------------------------------------------
  171. * data/storage
  172. *-------------------------------------------------------------------------
  173.         ds.w    0
  174.  
  175. aespb   dc.l    contrl,global,intin,intout,addrin,addrout
  176. vdipb   dc.l    contrl,intin,ptsin,intout,ptsout
  177. xpos    dc.w    1
  178. ypos    dc.w    1
  179. resrce  dc.b    'MENU.RSC',00,00
  180.  
  181. mouse
  182. mask
  183.         dc.w    %0100000000000000
  184.         dc.w    %1110000000000000
  185.         dc.w    %1111000000000000
  186.         dc.w    %1111100000000000
  187.         dc.w    %1111110000000000
  188.         dc.w    %1111111000000000
  189.         dc.w    %1111111100000000
  190.         dc.w    %1111111110000000
  191.         dc.w    %1111111111000000
  192.         dc.w    %1111111111100000
  193.         dc.w    %1111111000000000
  194.         dc.w    %1110111100000000
  195.         dc.w    %1100111100000000
  196.         dc.w    %0000011110000000
  197.         dc.w    %0000011110000000
  198.         dc.w    %0000001100000000
  199.  
  200. data
  201.         dc.w    %0000000000000000
  202.         dc.w    %0100000000000000
  203.         dc.w    %0110000000000000
  204.         dc.w    %0111000000000000
  205.         dc.w    %0111100000000000
  206.         dc.w    %0111110000000000
  207.         dc.w    %0111111000000000
  208.         dc.w    %0111111100000000
  209.         dc.w    %0111111110000000
  210.         dc.w    %0111110000000000
  211.         dc.w    %0110110000000000
  212.         dc.w    %0100011000000000
  213.         dc.w    %0000011000000000
  214.         dc.w    %0000001100000000
  215.         dc.w    %0000001100000000
  216.         dc.w    %0000000000000000
  217.  
  218. sbss    equ     *                  ;this is the only way to define a bss
  219.                                    ;section in the GST assembler
  220.  
  221. contrl  equ     sbss
  222. opcode  equ     contrl
  223. sintin  equ     opcode+2
  224. sintout equ     sintin+2
  225. saddrin equ     sintout+2
  226. sadrout equ     saddrin+2
  227.  
  228. global  equ     sadrout+14
  229. apvers  equ     global
  230. apcount equ     apvers+2
  231. apid    equ     apcount+2
  232. appriv  equ     apid+2
  233. apptree equ     appriv+4
  234. ap1resv equ     apptree+4
  235. ap2resv equ     ap1resv+4
  236. ap3resv equ     ap2resv+4
  237. ap4resv equ     ap3resv+4
  238.  
  239. intin   equ     ap4resv+4
  240. ptsin   equ     intin+256
  241. intout  equ     ptsin+256
  242. ptsout  equ     intout+256
  243. addrin  equ     ptsout+256
  244. addrout equ     addrin+256
  245.  
  246. grhand  equ     addrout+256
  247. buffer  equ     grhand+2
  248. stack   equ     grhand+16+1200
  249. ebss    equ     stack+20
  250.  
  251.         END
  252.  
  253.